package com.paradise.ytj.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Administrator on 2017/8/15 0015.
 */

public class MyDBOpenHelper extends SQLiteOpenHelper {
    public MyDBOpenHelper(Context context) {
        super(context, "face.db", null, 2);
    }

    // 在mydbOpenHelper 在数据库第一次被创建的时候  会执行onCreate();
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE contact (id integer  primary key  autoincrement, name varchar(20),account varchar(20))");
        db.execSQL("CREATE TABLE record (id integer  primary key autoincrement, name varchar(20),account varchar(20),time varchar(50))");
        onUpgrade(db, 1, 2);
    }

    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if (newVersion > oldVersion) {
            db.execSQL("ALTER TABLE record ADD call varchar(20);");
        }

    }
}
